import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  server: {
    proxy: {  // 代理
      '/api': {
        target: 'http://localhost:80',  // 代理地址, 比如： /api/user => http://localhost:80/user
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '')
      },
      '/foo': {
        target: 'http://localhsot:8080', // 代理地址, 比如： /foo/user => http://localhost:8080/user
        changeOrigin: true,
        rewrite: path => path.replace(/^\/foo/, '')
      }
    }
  }
})
